//cookie    "name=value; expires=date; path=xx; domain=xx; secure;
;
CookieTools =(function () {
    return {
        setCookie: function (name, value, timer, path, domain, secure) {
            var cookieStr = "";
            if (name) {
                cookieStr += encodeURIComponent(name) + "=" + encodeURIComponent(value) + ";"
            }
            if (typeof(timer)=="number") {
                var date = new Date();
                date.setDate(date.getDate() + timer);
                cookieStr += "expires=" + date.toUTCString() + ";"
            }
            if (path) {
                cookieStr += "path=" + path + ";"
            }
            if (domain) {
                cookieStr += "domain=" + domain + ";"
            }
            if (secure) {
                cookieStr += "secure";
            }
            return document.cookie = cookieStr;
        },
        getCookieAll: function () {
            var obj = {};
            var cookieStr = decodeURIComponent(document.cookie);
            var arr = cookieStr.split(";");
            arr.forEach(function (el, index) {
                var arr1 = el.split("=");
                obj[arr1[0].trim()] = arr[1]
            });
            return obj;
        },
        getCookieByName: function (name) {
            return this.getCookieAll()[name];
        },
            removeCookie: function () {
            this.setCookie(name, "", -1)
        }

    }
})();